//
//  ZLGiftCellContentView.m
//  ZLYoYoIM-ZLYoYoIM
//
//  Created by 赵磊 on 2021/1/21.
//

#import "ZLGiftCellContentView.h"
#import <UIButton+WebCache.h>
#import "ZLAttachment.h"
#import "UIImage+ZLIMCustom.h"

@implementation ZLGiftCellContentView

- (instancetype)initSessionMessageContentView{
    if (self = [super initSessionMessageContentView]) {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 120.0, 120.0)];
        [self addSubview:button];
        self.unitView = button;
    }
    return self;
}

- (void)refresh:(NIMMessageModel*)data{
    //务必调用super方法
    [super refresh:data];
    NIMCustomObject *object = data.message.messageObject;
    ZLAttachment *attachment = object.attachment;
    //识别方向
    __weak typeof(self)weakSelf = self;
    [self.unitView sd_setImageWithURL:[NSURL URLWithString:attachment.url] forState:UIControlStateNormal placeholderImage:nil options:0 completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        [weakSelf.unitView setImage:image forState:UIControlStateNormal];
    }];
    
    
}

@end
